//引入二次封装的axios
import request from "@/utils/request.ts";
import {
    AddOrUpdateUser,
    AllOrderStatusResponseData,
    AllUserResponseData,
    CertificateTypeResponseData,
    OrderResponseData,
    PayResult,
    QrCode,
    SubmitOrder, UserCertificateParams,
    UserInfoResponseData, UserOrderInfoResponseData
} from "@/api/user/type.ts";
//枚举地址
enum API {
    //提交订单,获取订单号
    SUBMITORDER_URL = "/order/orderInfo/auth/submitOrder/",
    //获取订单详情的数据
    GETORDERINFO_URL = "/order/orderInfo/auth/getOrderInfo/",
    //取消订单的接口
    ORDERCANCEL_URL = "/order/orderInfo/auth/cancelOrder/",
    //获取支付订单二维码
    QRCODE_URL = "/order/weixin/createNative/",
    //查询订单支付状态的结果
    PAYRWSULT_URL = "/order/weixin/queryPayStatus/",
    //获取当前账号的用户信息
    USERINFO_URL = "/user/auth/getUserInfo/",
    //获取证件类型接口
    CERTIFICATIONTYPE_URL = "/cmn/dict/findByDictCode/",
    //用户认证
    USERCERTIFICATION_URL = "/user/auth/userAuah",
    //获取用户订单号
    USERORDERINFO_URL = "/order/orderInfo/auth/",
    //获取全部就诊人的信息
    ALLUSERL_URL = "/user/patient/auth/findAll/",
    //获取订单状态
    ORDERSTATE_URL = "/order/orderInfo/auth/getStatusList",
    //获取城市数据
    CITY_URL = "/cmn/dict/findByParentId/",
    //新增就诊人
    ADDUSER_URL = "/user/patient/auth/save",
    //更新就诊人
    UPDATEUSER_URL = "/user/patient/auth/update",
    //删除已有的就诊人
    DELETEUSER_URL = "/user/patient/auth/remove/"
};
//提交订单
export const reqSubmitOrder = (hoscode: string, scheduleId: string, patientId: number) => request.post<any,SubmitOrder>(API.SUBMITORDER_URL + `${hoscode}/${scheduleId}/${patientId}`);
//获取订单详情的方法
export const regOrderInfo = (id: string) => request.get<any, OrderResponseData>(API.GETORDERINFO_URL + id);
//取消订单
export const regCancelOrder = (id: string) => request.get<any, any>(API.ORDERCANCEL_URL + id);
//获取支付二维码
export const reqQrcode = (orderId: string) => request.get<any,QrCode>(API.QRCODE_URL + orderId);
//查询订单支付的结果
export const reqQueryPayState = (orderId: string) => request.get<any,PayResult>(API.PAYRWSULT_URL + orderId);
//获取当前用户信息
export const reqUserInfo = () => request.get<UserInfoResponseData,any>(API.USERINFO_URL);
//获取证件类型的方法
export const reqCertificateType = (CertificatesType='CertificatesType') => request.get<any,CertificateTypeResponseData>(API.CERTIFICATIONTYPE_URL + CertificatesType);
//用户认证接口
export const reqUserCertificate = (data: UserCertificateParams) => request.post<any,any>(API.USERCERTIFICATION_URL, data);
//获取订单数据的接口
export const reqUserOrderInfo = (page: number, limit: number, patientId:string, orderStatus:string) => request.get<any, UserOrderInfoResponseData>(API.USERORDERINFO_URL + `${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`);
// 获取全部就诊人的信息
export const reqAllUser = () => request.get<any, AllUserResponseData>(API.ALLUSERL_URL);
//获取全部订单的请求接口
export const reqAllOrderStatus = () => request.get<any, AllOrderStatusResponseData>(API.ORDERSTATE_URL);
//获取城市数据
export const reqCity = (parentId: string) => request.get<any,any>(API.CITY_URL + parentId);

//新增和修改已有的就诊人
export const reqAddOrUpdateUser = (data: AddOrUpdateUser) => {
    if (data.id) {
        return request.put<any,any>(API.UPDATEUSER_URL, data);
    } else {
        return request.post<any,any>(API.ADDUSER_URL, data);
    }
};
//删除已有就诊人信息
export const reqRemoveUser = (id: number) => request.delete<any, any>(API.DELETEUSER_URL + id);



















